//
//  AllViewController.m
//  Zaker
//
//  Created by 赵磊 on 16/3/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "AllViewController.h"

@interface AllViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArr;
@end

@implementation AllViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView registerClass:[BaseTableViewCell class] forCellReuseIdentifier:@"cell"];
    self.dataArr = [_allArr mutableCopy];
    [_dataArr removeObjectAtIndex:1];
    [_dataArr removeObjectAtIndex:3];
    [self.view addSubview:_tableView];
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   BaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.textLabel.text = [_dataArr[indexPath.row] objectForKey:@"title"];
    cell.textLabel.textColor  = [ UIColor grayColor];
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //详情的连接
    NSString *str = [_dataArr[indexPath.row] objectForKey:@"api_url"];
    NSString *titleStr = [_dataArr[indexPath.row] objectForKey:@"title"];
    CellDetailViewController *cellVC = [[CellDetailViewController alloc]init];
    cellVC.str = str;
    cellVC.titleStr = titleStr;
    [self.navigationController pushViewController:cellVC animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
